IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name = 'EDUCATION_MODULE')
BEGIN
    DROP TABLE [dbo].[EDUCATION_MODULE]
END

GO

CREATE TABLE [dbo].[EDUCATION_MODULE] ( 
	[ID]			    INT IDENTITY(1,1)   NOT FOR REPLICATION NOT NULL,
    [NAME]              VARCHAR(20)         NOT NULL	UNIQUE,
    [DESCRIPTION]       VARCHAR(256),
    [PARTICIPANT_TYPE]  VARCHAR(10)         NOT NULL CONSTRAINT [CK_EDUCATION_MODULE_PARTICIPANT_TYPE]
            CHECK NOT FOR REPLICATION (PARTICIPANT_TYPE IN ('Personal', 'Group'))
            DEFAULT 'Personal',
    [HOLDING_TYPE]      VARCHAR(10)         NOT NULL CONSTRAINT [CK_EDUCATION_MODULE_HOLDING_TYPE]
            CHECK NOT FOR REPLICATION (HOLDING_TYPE IN ('Offline', 'Online'))
            DEFAULT 'Offline',
    [NEED_APPROVE]      BIT                 NOT NULL,
    [PUBLIC_ASSIGNE]    BIT                 NOT NULL,
    [PAY]               INT,
    [PAY_CURRENCY]      VARCHAR(10),
    [DURATION]          INT,
    [DURATON_TYPE]      VARCHAR(10)         CONSTRAINT [CK_EDUCATION_MODULE_DURATON_TYPE]
            CHECK NOT FOR REPLICATION (DURATON_TYPE IN ('hours', 'days', 'months', 'years'))
            DEFAULT 'hours',
    [LABELS]            VARCHAR(256),
    [DIFFICULT]         VARCHAR(10)         CONSTRAINT [CK_EDUCATION_MODULE_DIFFICULT]
            CHECK NOT FOR REPLICATION (DIFFICULT IN ('Easy', 'Pre intermediate', 'Intermediate', 'Upper intermediate', 'Hight'))
            DEFAULT 'Intermediate',
    [STATUS]            VARCHAR(10)         CONSTRAINT [CK_EDUCATION_MODULE_STATUS]
            CHECK NOT FOR REPLICATION (STATUS IN ('Open', 'When in use', 'Close'))
            DEFAULT 'Open'

    CONSTRAINT [PK_EDUCATION_MODULE_ID] PRIMARY KEY CLUSTERED ( 
        [ID] 
    ) ON [PRIMARY]
    
) ON [PRIMARY]  

GO